package chainofresponsibility;

public class ChainOfResponsibilityPattern {

    public static void main(String[] args) {
        SpamHandler spamHandler = new SpamHandler();
        FanHandler fanHandler = new FanHandler();
        ComplaintHandler complaintHandler = new ComplaintHandler();
        NewLocHandler newLocHandler = new NewLocHandler();
        DefaultHandler defaultHandler = new DefaultHandler();

        spamHandler.setSuccessor(fanHandler);
        fanHandler.setSuccessor(complaintHandler);
        complaintHandler.setSuccessor(newLocHandler);
        newLocHandler.setSuccessor(defaultHandler);

        Email spamEmail = new Email(EmailEnum.SPAM_EMAIL, "spam email -- HA! HA! HA!");
        Email fanEmail = new Email(EmailEnum.FAN_EMAIL, "fan email -- Candy machine is so cool!");
        Email complaintEmail = new Email(EmailEnum.COMPLAINT_EMAIL, "complaint email -- I hate candy machine!");
        Email newLocEmail = new Email(EmailEnum.NEW_LOC_EMAIL, "new loc email -- We hope to set up a candy machine in the mall.");
        Email email = new Email(null, "I need help!!!");

        spamHandler.handleRequest(spamEmail);
        spamHandler.handleRequest(fanEmail);
        spamHandler.handleRequest(complaintEmail);
        spamHandler.handleRequest(newLocEmail);
        spamHandler.handleRequest(email);
    }
}
